package com.fms.model.domain;

import java.util.Calendar;

public class FlowSheet
{
	private String	fileName;
	private Calendar	date;
	public FlowSheet(String _fileName)
	{
		this.fileName = _fileName;
	}

	public String getFileName()
	{
		return fileName;
	}

	public void setFileName(String _value)
	{
		this.fileName = _value;
	}

	public void setDate(Calendar _date)
	{
		this.date = _date;
	}

	public Calendar getDate()
	{
		return this.date;
	}
	
	public Calendar getFirstReadingTime()
	{
		Calendar rounded = (Calendar)this.date.clone();
		rounded.add(Calendar.MINUTE, 5);
		
		int minute = rounded.get(Calendar.MINUTE);
		
		int roundedMinute = (int) Math.ceil(((double)minute)/5) * 5;		
		int difference = roundedMinute - minute;		
		rounded.add(Calendar.MINUTE, difference);
		
		return rounded;
		
	}
	
	public Calendar getReadingTime(int number)
	{
		Calendar rounded = getFirstReadingTime();
		
		rounded.add(Calendar.MINUTE, number * 30);
		
		return rounded;
		
	}
	
	public Calendar getEndTime()
	{
		Calendar c = (Calendar)this.date.clone();
		c.add(Calendar.MINUTE, 165);
		return c;
	}
}
